

layui.define(['jquery', 'httpService', 'httpRouter', 'DateFormat'],function(exports){
  //do something
  var $ = layui.jquery,
    DateFormat = layui.DateFormat,
    http = layui.httpService,
    httpRouter = layui.httpRouter;



  var common = {
    getBaseInfo:function () {
      http.get(httpRouter.baseinfo,{},function (res) {
        console.log(res)
        $('#logo').attr('url',res.companyImgUrl);
        $('#hospitalName').html(res.hospitalName);
        $('#defaultDepNo').html(res.defaultDepNo);
        $('#copyright').html(res.copyright);
        $('#h-user').html(res.userName);
      });
    },
    getMenus:function(index) {
      http.get(httpRouter.basemenu,{},function (res) {
        console.log(res.records);
          $.each(res.records,function(i,obj){
            $('#menus').append('<a class="menu '+(index == i ? 'active' : '')+'" href="'+obj.PageUrl+'">' +
              '          <img src="'+obj.PageCode+'" class="icon">' +
              '          <p>'+obj.PageName+'</p>' +
              '        </a>')


          })

      });
    },
    clock:function(){
      var year = DateFormat.format(new Date(), 'yyyy-MM-dd');
      var time = DateFormat.format(new Date(), 'hh:mm');
      var week = DateFormat.getWeek(new Date(), 0);
      $('.time-board #year').html(year);
      $('.time-board #time').html(time);
      $('.time-board #week').html(week);
      setTimeout(this.clock,1000);
    },
    init:function () {
      this.getBaseInfo();
      this.clock();
      $('#btn-exit').on('click',function () {
        window.location = './login.html';
      });
    }
  }
  exports('common', common);
});
